import { ProFieldFC } from '@ant-design/pro-components';
import React from 'react';
import SfwAliyunOSSUpload from '../../../form/SfwAliyunOSSUpload';

/**
 * 代码片段组件 这个组件为了显示简单的配置，复杂的请使用更加重型的组件
 */
const FieldSfwAliyunOSSUpload: ProFieldFC<{
  text: any;
}> = (props, ref) => {
  const { text, mode, fieldProps } = props;

  if (mode === 'read') {
    return (
      <SfwAliyunOSSUpload ref={ref} {...fieldProps} value={text} readOnly />
    );
  }
  if (mode === 'edit' || mode === 'update') {
    return <SfwAliyunOSSUpload ref={ref} {...fieldProps} />;
  }
  return null;
};

export default React.forwardRef(FieldSfwAliyunOSSUpload);
